package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
)

func main() {
	router:=gin.Default()
	router.Use(ShowRequestInfo)//使用中间件

	router.GET("", func(ctx *gin.Context) {
		ctx.String(http.StatusOK,"123")
	})
	router.Run()
}
//自定义中间件1
func ShowRequestInfo(ctx *gin.Context){
	path := ctx.FullPath()
	method := ctx.Request.Method
	fmt.Println("path:"+path)
	fmt.Println("method:"+method)
}